<template>
  <div class="checkMoreData">
    <!-- 弹窗 头部 -->
    <van-nav-bar left-arrow="true" @click-left="moreDateHeaderClickLeft">
      <span slot="title" class="header_text">
        <span>[客队]</span>
        {{moreItem.guest}}&nbsp;&nbsp;VS&nbsp;&nbsp;{{moreItem.host}}
        <span>[主队]</span>
      </span>
    </van-nav-bar>
    <div class="content">
      <template>
        <div class="playItem">
          <h3>胜负</h3>
          <div class="box">
            <div class="center_center_left">
              <p class="purple">非让分</p>
              <p class="blue">让分</p>
            </div>
            <div class="center_right_box">
              <div class="normal">
                <div class="text_box">
                  <template v-if="moreItem.odds_1">
                    <div
                      :key="moreItem.odds_1[1].value"
                      :class="['item',{'chose':moreItem.odds_1[1].is_choice}]"
                      @click="chose(moreItem.odds_1[1])"
                    >
                      客胜
                      <span class="odds">{{moreItem.odds_1[1].odds}}</span>
                    </div>
                    <div
                      :key="moreItem.odds_1[0].value"
                      :class="['item',{'chose':moreItem.odds_1[0].is_choice}]"
                      @click="chose(moreItem.odds_1[0])"
                    >
                      主胜
                      <span class="odds">{{moreItem.odds_1[0].odds}}</span>
                    </div>
                  </template>
                  <template v-else>
                    <div class="center_right_box_no">未开售</div>
                  </template>
                </div>
                <div class="text_box flexBox">
                  <template v-if="moreItem.odds_2">
                    <div
                      :key="moreItem.odds_2[1].value"
                      :class="['item',{'chose':moreItem.odds_2[1].is_choice}]"
                      @click="chose(moreItem.odds_2[1])"
                    >
                      让客胜
                      <span class="odds">{{moreItem.odds_2[1].odds}}</span>
                    </div>
                    <div
                      :key="moreItem.odds_2[0].value"
                      :class="['item',{'chose':moreItem.odds_2[0].is_choice}]"
                      @click="chose(moreItem.odds_2[0])"
                    >
                      让主胜
                      <span class="odds">{{moreItem.odds_2[0].odds}}</span>
                    </div>
                    <div class="item mark">{{moreItem.rq|compareProfit}}</div>
                  </template>
                  <template v-else>
                    <div class="center_right_box">未开售</div>
                  </template>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="playItem dxScore">
          <h3>大小分</h3>
          <div class="box">
            <div class="center_center_left">
              <p class="purple">大小分</p>
            </div>
            <div class="center_right_box">
              <div class="normal">
                <div class="text_box">
                  <template v-if="moreItem.odds_4">
                    <div
                      :key="moreItem.odds_4[0].value"
                      :class="['item',{'chose':moreItem.odds_4[0].is_choice}]"
                      @click="chose(moreItem.odds_4[0])"
                    >
                      大
                      <span class="odds">{{moreItem.odds_4[0].odds}}</span>
                    </div>
                    <div
                      :key="moreItem.odds_4[1].value"
                      :class="['item',{'chose':moreItem.odds_4[1].is_choice}]"
                      @click="chose(moreItem.odds_4[1])"
                    >
                      小
                      <span class="odds">{{moreItem.odds_4[1].odds}}</span>
                    </div>
                    <div class="item mark">{{moreItem.sd}}</div>
                  </template>
                  <template v-else>
                    <div class="center_right_box">未开售</div>
                  </template>
                </div>
              </div>
            </div>
          </div>
        </div>
      </template>

      <!-- 胜分差-->
      <div class="playItem shengfenItem">
        <h3>胜分差</h3>
        <div class="box">
          <div class="center_center_left">
            <p class="purple">客胜</p>
            <p class="blue">主胜</p>
          </div>
          <div class="center_right_box">
            <div class="normal_odds3">
              <template v-if="odds_3">
                <div
                  v-for="item in odds_3"
                  :key="item.odds+item.value"
                  :class="['item_odds3',{'chose':item.is_choice}]"
                  @click="chose(item)"
                >
                  ({{item.value|mapVal}})
                  <span class="odds">{{item.odds}}</span>
                </div>
              </template>
              <template v-else>
                <div class="center_right_box_no special">未开售</div>
                <div class="center_right_box_no special">未开售</div>
              </template>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="btn_group flexBox">
      <van-button type="default" class="bottomBut close" @click="cancel">取消</van-button>
      <van-button type="danger" class="bottomBut" @click="sure">确定</van-button>
    </div>
  </div>
</template>
<script>
import { NavBar, Button } from "vant";

export default {
  name: "basketball_more",
  components: {
    NavBar,
    Button
  },
  props: {
    moreItem: {
      type: Object
    }
  },
  data() {
    return {
      cloneData: {},
      shopcarClone: {}
    };
  },
  watch: {
    moreItem(moreItem) {
      console.log(moreItem, "mroeItem");
      this.cloneData = JSON.parse(JSON.stringify(moreItem));
    }
  },
  filters: {
    mapVal(val) {
      let score = (val + "").split("-")[1];

      if (score == 26) {
        return "26+";
      }
      return score * 1 - 4 + "-" + score;
    }
  },
  computed: {
    odds_3() {
      //胜分差
      if (this.moreItem.odds_3) {
        let host = this.moreItem.odds_3.slice(0, 6);
        let guest = this.moreItem.odds_3.slice(6);
        return guest.concat(host);
      } else {
        return null;
      }
    }
  },
  created() {
    // this.concatData();
    // shopcarAdd(123,232,44)
    // console.log(this.moreItem)
  },
  activated() {
    console.log("2222222222222");
  },
  methods: {
    moreDateHeaderClickLeft() {
      this.$emit("closeMoreDatemodel");
    },
    concatData() {
      this.cloneData = JSON.parse(JSON.stringify(this.moreItem));
      // this.shopcarClone = JSON.parse(JSON.stringify(this.shopcar))
    },
    chose(item) {
      item.is_choice = !item.is_choice;
    },
    cancel() {
      this.$emit("closeMoreDatemodel", this.cloneData);
    },
    sure() {
      this.$emit("closeMoreDatemodel");
    }
  }
};
</script>
<style lang="less" >
.checkMoreData {
  .font(@font_size:12px,@line_height:12px,@color:#333,@text_align:center) {
    font-size: @font_size;
    font-style: normal;
    line-height: @line_height;
    color: @color;
    text-align: @text_align;
  }
  .normal {
    .flexBox {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .item {
        border-bottom: none;
      }
    }
  }
  .flexBox {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .bottomBut {
      width: 100%;
    }
  }

  .more {
    padding-top: 45px;
    min-height: 100vh;
    position: fixed;
    left: 0;
    bottom: 0;
    top: 0;
    right: 0;
    z-index: 100;
    background-color: #f4f4f4;
  }
  .header_text {
    .font(18px, 45px, #fff);
    font-weight: normal;
    span {
      font-size: 12px;
    }
  }
  .content {
    padding: 12px 10px;
  }
  .playItem {
    margin-bottom: 11px;
    h3 {
      .font(14px, 17px, #333, left);
      margin-bottom: 10px;
      &::before {
        display: inline-block;
        content: "";
        width: 3px;
        height: 17px;
        background-color: #ff4536;
        margin-right: 10px;
        vertical-align: bottom;
      }
    }
  }
  .dxScore {
    .box {
      .normal {
        .item {
          border-bottom: none;
        }
      }
    }
  }
  .box {
    border-radius: 3px;
    background-color: #fff;
    display: flex;
    overflow: hidden;
  }
  .center_center_left {
    width: 18px;
    .font(10px, 14px, #fff);
    background-color: #333333;
    border-radius: 3px 0 0 3px;
    display: flex;
    flex-direction: column;
    .purple,
    .blue {
      flex: 1;
      display: flex;
      align-items: center; /*垂直居中*/
      justify-content: center; /*水平居中*/
    }
    .purple {
      line-height: 12px;
      border-bottom: 1px solid #eaeaea;
    }
    .blue {
    }
  }
  .center_right_box_no {
    flex: 1;
    &.special {
      flex: 0 0 100%;
      height: 126px;
      line-height: 126px;
    }
    &:nth-child(1) {
      border-bottom: 1px solid #eaeaea;
    }
  }
  .center_right_box {
    flex: 1;

    border-radius: 0 3px 3px 0;
    border-left: 0;
    border-bottom: 0;
    &.special {
      flex: 0 0 100%;
      height: 126px;
      line-height: 126px;
    }
    .normal {
      flex: 1;
      .font(12px, 40px, #333);
      flex-wrap: wrap;
      border: 1px solid #eaeaea;
      .text_box {
        display: flex;
      }
    }
    .normal_odds3 {
      .font(12px, 40px, #333);
      flex-wrap: wrap;
      display: flex;
      border-top: 1px solid #eaeaea;
      border-right: 1px solid #eaeaea;
      .item_odds3 {
        flex: 49%;
        border-left: 1px solid #eaeaea;
        border-bottom: 1px solid #eaeaea;
      }
      .item_odds3.chose {
        background-color: #ff4536;
        color: #fff;
        .odds {
          color: #fff;
        }
      }
    }
    .odds {
      color: #9b9b9b;
    }
    .item {
      flex: 1;
      border-left: 1px solid #eaeaea;
      border-bottom: 1px solid #eaeaea;
      order: 2;
    }
    .item:first-child {
      border-left: none;
      order: 1;
    }
    .mark {
      flex: 0 0 80px;
      color: #5bb2ff;
      order: 1;
    }
    .more {
      width: 80px;
      .font(10px, 14px, #333);
    }
    .chose {
      color: #ff4536;
    }
    .item.chose {
      background-color: #ff4536;
      color: #fff;
      .odds {
        color: #fff;
      }
    }
  }
  .shengfenItem {
    .center_center_left .purple {
    }
  }

  .btn_group {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 375px;
    .btn {
      flex: 1;
      height: 50px;
      border-radius: 0;
      .font(16px, 50px, #fff);
    }
    .close {
      border:1px solid #DCDCDC;
      background-color: #DCDCDC;
    }
    .sure {
      background-color: #ff4536;
    }
  }
}
// vant 样式覆盖
.van-popup {
  .van-button {
    border-radius: 0;
  }
}
</style>
